<include file="public@header"/>
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('grade/index')}">成绩列表</a></li>
        <li class="active"><a href="{:url('grade/add')}">添加成绩</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('grade/addPost')}">
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">成绩名称<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="name">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">所属学校<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10" >
                <select class="form-control" name="" id="selectSchool" >
                    <option value="0">|--请选择学校--|</option>
                    <foreach name="school" item="vo">
                        <option value="{$vo.id}">{$vo.name}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">所属班级<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10" >
                <select  id="selectRoom" class="form-control">
                    <option value="">|--请选择班级--|</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">学生<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10" >
                <select name="student_id" id="student_id" class="form-control">
                    <option value="">|--请选择学生--|</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">学科<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10" >
                <select name="course_id" class="form-control">
                    <option value="">|--请选择学科--|</option>
                    <foreach name="course" item="vo">
                        <option value="{$vo.id}">{$vo.name}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                <a class="btn btn-default" href="{:url('grade/index')}">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $(function () {
        $('#selectSchool').change('click',function () {
            var schoolId=$('#selectSchool').val();
            $.ajax({
                url:"{:url('grade/getRoomBySchool')}",
                type:"POST",
                data:{school_id:schoolId},
                success:function (res) {
                    console.log(res);
                    $('#selectRoom').html(res);
                }
            })
        })
    });
    $(function () {
        $('#selectRoom').change('click',function () {
            var roomId=$('#selectRoom').val();
            $.ajax({
                url:"{:url('grade/getStudentByRoom')}",
                type:"POST",
                data:{room_id:roomId},
                success:function (res) {
                    console.log(res);
                    $('#student_id').html(res);
                }
            })
        })
    })
</script>
</body>
</html>